<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        function fn(i) {
            return function (n) {
                console.log(n + (i++))
            }
        }
        // var f = fn(2)
        // f(3) //4
        // fn(4)(5)  // 8
        // fn(6)(7) //12
        // f(8) // 8
        var f = fn(10) 
        f(20) //  30
        fn(20)(30)  //  50
        fn(30)(50) //  80
        f(30) //  41
    </script>
</body>

</html>